import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'

import usrRoleService from '/@/api/cn/core/sign/usrRoleService'

import type { UsrRole } from '/@/model/cn/core/sign/eo/UsrRole'
import type { UsrRoleQO } from '/@/model/cn/core/sign/qo/UsrRoleQO'
import type { UsrRoleVO } from '/@/model/cn/core/sign/vo/UsrRoleVO'

interface UsrRoleState {
}

export const useUsrRoleStore = defineStore({
  id: 'usrRole',
  state: (): UsrRoleState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<UsrRole>): Promise<Res<UsrRole>> {
      return new Promise<Res<UsrRole>>((resolve, reject) => {
        usrRoleService.save(param).then((res: AxiosResponse<Res<UsrRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<UsrRole>): Promise<Res<UsrRole>> {
      return new Promise<Res<UsrRole>>((resolve, reject) => {
        usrRoleService.saveBatch(param).then((res: AxiosResponse<Res<UsrRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<UsrRole>): Promise<Res<UsrRole>> {
      return new Promise<Res<UsrRole>>((resolve, reject) => {
        usrRoleService.update(param).then((res: AxiosResponse<Res<UsrRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<UsrRole>): Promise<Res<UsrRole>> {
      return new Promise<Res<UsrRole>>((resolve, reject) => {
        usrRoleService.updateBatch(param).then((res: AxiosResponse<Res<UsrRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<UsrRole>): Promise<Res<UsrRole>> {
      return new Promise<Res<UsrRole>>((resolve, reject) => {
        usrRoleService.remove(param).then((res: AxiosResponse<Res<UsrRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<UsrRole>): Promise<Res<UsrRole>> {
      return new Promise<Res<UsrRole>>((resolve, reject) => {
        usrRoleService.removeBatch(param).then((res: AxiosResponse<Res<UsrRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<UsrRoleQO>): Promise<Res<UsrRole>> {
      return new Promise<Res<UsrRole>>((resolve, reject) => {
        usrRoleService.count(param).then((res: AxiosResponse<Res<UsrRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<UsrRoleQO>): Promise<Res<UsrRole>> {
      return new Promise<Res<UsrRole>>((resolve, reject) => {
        usrRoleService.pk(param).then((res: AxiosResponse<Res<UsrRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<UsrRoleQO>): Promise<Res<UsrRole>> {
      return new Promise<Res<UsrRole>>((resolve, reject) => {
        usrRoleService.query(param).then((res: AxiosResponse<Res<UsrRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<UsrRoleQO>): Promise<Res<UsrRole>> {
      return new Promise<Res<UsrRole>>((resolve, reject) => {
        usrRoleService.paging(param).then((res: AxiosResponse<Res<UsrRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<UsrRoleQO>): Promise<Res<UsrRoleVO>> {
      return new Promise<Res<UsrRoleVO>>((resolve, reject) => {
        usrRoleService.countVo(param).then((res: AxiosResponse<Res<UsrRoleVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<UsrRoleQO>): Promise<Res<UsrRoleVO>> {
      return new Promise<Res<UsrRoleVO>>((resolve, reject) => {
        usrRoleService.pkVo(param).then((res: AxiosResponse<Res<UsrRoleVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<UsrRoleQO>): Promise<Res<UsrRoleVO>> {
      return new Promise<Res<UsrRoleVO>>((resolve, reject) => {
        usrRoleService.queryVo(param).then((res: AxiosResponse<Res<UsrRoleVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<UsrRoleQO>): Promise<Res<UsrRoleVO>> {
      return new Promise<Res<UsrRoleVO>>((resolve, reject) => {
        usrRoleService.pagingVo(param).then((res: AxiosResponse<Res<UsrRoleVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useUsrRoleStoreWithout() {
  return useUsrRoleStore(store)
}
